import Vue from 'vue'
import Vuex from 'vuex'
import axios from '../http/request'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    list: []
  },
  mutations: {
    CHANGE_LIST(state, { list }) {
      state.list = list
    },
    CHNAGE_ITEM(state, { index }) {
      state.list[index].flag = !state.list[index].flag
    }
  },
  actions: {
    INIT_LIST({ commit }) {
      axios.get('/getList').then(list => {
        commit("CHANGE_LIST", {
          list
        })
      })
    }
  },
  modules: {
  }
})
